package gui.framework.intent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import gui.utils.CastUtils;

public class Intent {
	/**
	 * 
	 */
	public static interface action {
		String MAIN = "gui.intent.action.MAIN";
	}

	public static interface category {
		String LAUNCHER = "gui.intent.category.LAUNCHER";
	}
	//

	private String action_str;
	private List<String> category_list;
	private Bundle bundle;
	private Map<String, Object> extra=new HashMap<>();

	public Intent() {
	}

	public void setAction(String action) {
		this.action_str = action;
	}

	public Intent(String action) {
		this.action_str = action;
	}

	public void addCategory(String category) {
		if (category_list == null) {
			category_list = new ArrayList<>();
		}
		category_list.add(category);
	}

	public String getAction() {
		return action_str;
	}

	public List<String> getCategorys() {
		return category_list;
	}

	public void putExtra(Bundle bundle) {
		this.bundle = bundle;
	}

	public Bundle getExtra() {
		return bundle;
	}

	public void putInt(String key, int value) {
		extra.put(key, value);
	}

	public int getInt(String key) {
		return CastUtils.castInt(extra.get(key));
	}

	public void putBoolean(String key, boolean value) {
		extra.put(key, value);
	}

	public boolean getBoolean(String key) {
		return CastUtils.castBoolean(extra.get(key));
	}

	public void put(String key, String value) {
		extra.put(key, value);
	}

	public String get(String key) {
		return CastUtils.castString(extra.get(key));
	}
}
